import express from 'express';
import { fileInterceptor } from './swiper.middleware';
import * as swiperRouter from './swiper.controller';
import { authGuard } from '../auth/auth.middleware';

const router = express.Router();

/**
 * 获取内容
 */
router.get('/swiper', swiperRouter.index);

/**
 * 获取首页筛选轮播图
 */
router.get('/swiperHome', swiperRouter.home);

/**
 * 获取内容(按 ID)
 */
router.get('/swiper/:postId', swiperRouter.swiperDetail);

/**
 * 创建内容
 */
router.post('/swiper', swiperRouter.store);

/**
 * 更新内容
 */
router.patch('/swiper/:postId', swiperRouter.update);

/**
 * 修改状态
 */
router.post('/changeSwiperStatus', authGuard, swiperRouter.status);

/**
 * 删除内容
 */
router.delete('/swiper/:postId', swiperRouter.destroy);
router.post('/delSwiper', swiperRouter.destroy);

/**
 * 上传文件
 */
router.post('/swiperFiles', fileInterceptor, swiperRouter.uploads);

/**
 * 文件服务
 */
router.get('/swiperFiles/:fileId/serve', swiperRouter.serve);

/**
 * 获取文件 ID
 */
router.post('/getSwiperFilesId', swiperRouter.getFileName)

/**
 * 导出路由
 */
export default router;
